package com.manage.system.controller;

import com.manage.system.context.DataSourceContextHolder;
import com.manage.system.dao.SeeDataBaseDao;
import com.manage.system.entity.BaseCheckSessionEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author liuzhao
 * @Date 2024/1/20 18:01
 * @Content
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/dynamicSource")
public class DynamicSourceController {

    @Autowired
    SeeDataBaseDao seeDataBaseDao;

    @RequestMapping(value = "/baseCheckSession", method = RequestMethod.GET)
    public BaseCheckSessionEntity getBaseCheckSessionData() {
        DataSourceContextHolder.setDataSource("see");
        BaseCheckSessionEntity baseCheckSessionData = seeDataBaseDao.getBaseCheckSessionData();
        DataSourceContextHolder.clearDataSource();
        log.info("查询数据为：{}", baseCheckSessionData);
        return baseCheckSessionData;
    }
}
